﻿Imports BaseballScoreKeeper.Core
Imports NUnit.Framework

Namespace BaseballScoreKeeper.Tests.CoreTests
    <TestFixture()> _
    Public Class Test_BaseballPlayer
#Region "Tests"
        <Test()> _
        Public Sub Test_Function_Equals()
            Dim expectedPlayerName As New Name("Babe", "Ruth")
            Dim expectedPlayerPositions As New List(Of BaseballFieldPosition)({
                BaseballFieldPosition.LeftField, BaseballFieldPosition.RightField, BaseballFieldPosition.Pitcher})
            Dim expectedPlayer As New BaseballPlayer(expectedPlayerName, expectedPlayerPositions, Handedness.LeftHanded, Handedness.LeftHanded)

            Dim testPlayerName1 As New Name("Babe", "Ruth")
            Dim testPlayerPositions1 As New List(Of BaseballFieldPosition)({
                BaseballFieldPosition.LeftField, BaseballFieldPosition.RightField, BaseballFieldPosition.Pitcher})
            Dim testPlayer1 As New BaseballPlayer(testPlayerName1, testPlayerPositions1, Handedness.LeftHanded, Handedness.LeftHanded)

            Dim testPlayerName2 As New Name("Ken", "Griffey", NameSuffix.Junior)
            Dim testPlayerPositions2 As New List(Of BaseballFieldPosition)({BaseballFieldPosition.CenterField})
            Dim testPlayer2 As New BaseballPlayer(testPlayerName2, testPlayerPositions2, Handedness.LeftHanded, Handedness.LeftHanded)

            Assert.AreEqual(expectedPlayer, testPlayer1)
            Assert.AreNotEqual(expectedPlayer, testPlayer2)
        End Sub

        <Test()> _
        Public Sub Test_Function_DoesPlayPosition()
            Dim testPlayerName As New Name("Babe", "Ruth")
            Dim testPlayerPositions As New List(Of BaseballFieldPosition)({
                BaseballFieldPosition.LeftField, BaseballFieldPosition.RightField, BaseballFieldPosition.Pitcher})
            Dim testPlayer As New BaseballPlayer(testPlayerName, testPlayerPositions, Handedness.LeftHanded, Handedness.LeftHanded)

            Assert.IsTrue(testPlayer.DoesPlayPosition(BaseballFieldPosition.LeftField))
            Assert.IsTrue(testPlayer.DoesPlayPosition(BaseballFieldPosition.RightField))
            Assert.IsTrue(testPlayer.DoesPlayPosition(BaseballFieldPosition.Pitcher))

            Assert.IsFalse(testPlayer.DoesPlayPosition(BaseballFieldPosition.Catcher))
            Assert.IsFalse(testPlayer.DoesPlayPosition(BaseballFieldPosition.CenterField))
            Assert.IsFalse(testPlayer.DoesPlayPosition(BaseballFieldPosition.FirstBase))
            Assert.IsFalse(testPlayer.DoesPlayPosition(BaseballFieldPosition.SecondBase))
            Assert.IsFalse(testPlayer.DoesPlayPosition(BaseballFieldPosition.ShortStop))
            Assert.IsFalse(testPlayer.DoesPlayPosition(BaseballFieldPosition.ThirdBase))
        End Sub

        <Test()> _
        Public Sub Test_Property_Name()
            Dim testPlayerName As New Name("Babe", "Ruth")
            Dim testPlayerPositions As New List(Of BaseballFieldPosition)({
                BaseballFieldPosition.LeftField, BaseballFieldPosition.RightField, BaseballFieldPosition.Pitcher})
            Dim testPlayer As New BaseballPlayer(testPlayerName, testPlayerPositions, Handedness.LeftHanded, Handedness.LeftHanded)

            Assert.AreEqual(testPlayerName, testPlayer.Name)
        End Sub

        <Test()> _
        Public Sub Test_Property_BattingDirection()
            Dim testPlayerName As New Name("Babe", "Ruth")
            Dim testPlayerPositions As New List(Of BaseballFieldPosition)({
                BaseballFieldPosition.LeftField, BaseballFieldPosition.RightField, BaseballFieldPosition.Pitcher})
            Dim testPlayer As New BaseballPlayer(testPlayerName, testPlayerPositions, Handedness.LeftHanded, Handedness.LeftHanded)

            Assert.AreEqual(Handedness.LeftHanded, testPlayer.BattingDirection)
        End Sub

        <Test()> _
        Public Sub Test_Property_ThrowingDirection()
            Dim testPlayerName As New Name("Babe", "Ruth")
            Dim testPlayerPositions As New List(Of BaseballFieldPosition)({
                BaseballFieldPosition.LeftField, BaseballFieldPosition.RightField, BaseballFieldPosition.Pitcher})
            Dim testPlayer As New BaseballPlayer(testPlayerName, testPlayerPositions, Handedness.LeftHanded, Handedness.LeftHanded)

            Assert.AreEqual(Handedness.LeftHanded, testPlayer.ThrowingDirection)
        End Sub
#End Region
    End Class
End Namespace